package com.mskj.zxmy.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.mskj.zxmy.common.Result;
import com.mskj.zxmy.dto.CKSQListQueryFo;
import com.mskj.zxmy.dto.PageResult;
import com.mskj.zxmy.entity.*;
import com.mskj.zxmy.service.NeckMaterialService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @BelongsProject: zxmy
 * @BelongsPackage: com.mskj.zxmy.controller
 * @Author: lk
 * @CreateTime: 2025-07-23
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@SaIgnore
@RequestMapping("/api/nm")
@RequiredArgsConstructor
@Tag(name = "领料单|扫码出库", description = "领料单|扫码出库")
@CrossOrigin
public class NeckMaterialController {

    private final NeckMaterialService neckMaterialService;


    @GetMapping("/lld-list")
    @Operation(description = "（领料）出库申请单列表", method = "GET")
    public Result<PageResult<RepositoryApplication>> lldList(@ParameterObject CKSQListQueryFo fo) {
        PageResult<RepositoryApplication> data = neckMaterialService.lldList(fo);
        return Result.success(data);
    }


    @GetMapping("/scan-ck-back-info")
    @Operation(description = "扫码回填出库单预创建信息", method = "GET")
    public Result<Lists> scanCkBackInfo(@Parameter(description = "出库申请单ID") Integer id) {
        return Result.success(neckMaterialService.scanCkBackInfo(id));
    }

    @GetMapping("/scan-to-get-item")
    @Operation(description = "扫码获取出库单", method = "GET")
    public Result<List<Ck02CheckoutFormCheckout>> scanToGetItem(@Parameter(description = "条码ID") Integer id) {
        return Result.success(neckMaterialService.scanToGetItem(id));
    }

    @PostMapping("/save-ckd")
    @Operation(description = "保存出库单", method = "POST")
    public Result<Boolean> saveCkd(@RequestBody Lists lists) {
        return Result.success(neckMaterialService.saveCkd(lists));
    }

}
